package com.zp.kidshop.shop.service.impl;

import java.util.List;
import java.util.Map;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import com.zp.kidshop.shop.entity.user.user_user;
import com.zp.kidshop.shop.service.UserService;
/**
 * @Title: UserServiceImpl.java
 * @Package com.zp.kidshop.shop.service.impl 
 * @Description: 用户表--实现接口层
 * @author 张鹏  
 * @date 2017年3月27日 下午5:36:11 
 * @version V1.0
 */
@Service
public class UserServiceImpl extends HibernateDaoSupport implements UserService{
	
	//
	public List<user_user> findbyfive(String type) {
		
		return null;
	}

	//
	public List<user_user> findAll(String type) {
		
		return null;
	}

	//登录
	@SuppressWarnings("unchecked")
	public user_user login(Map<String,String> parMap) {
		if(parMap.isEmpty()){
			return null;
		}
		String hql = "from user_user where (User_Email = ? and User_Password = ?) or (User_UserName = ? and User_Password = ?)";
		try{
			
			List<user_user> list = (List<user_user>) this.getHibernateTemplate().find(hql, parMap.get("username"),parMap.get("password"),parMap.get("username"),parMap.get("password"));
			if(list.size()>0){
				user_user user = list.get(0);
				return user;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}

}
